package com.wlcorp.forcazamis.dao.system.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ibatis.dao.client.DaoException;
import com.wlcorp.forcazamis.dao.system.ICompanyDAO;
import com.wlcorp.forcazamis.domain.system.Company;

public class CompanyDAOImpl extends HibernateDaoSupport implements ICompanyDAO {

	@SuppressWarnings("unchecked")
	public Company getCompany() throws DaoException {
		List list = new ArrayList();
		list = this.getHibernateTemplate().find("from Company");
		return ((null != list && list.size() > 0) ? (Company) list.get(0)
				: null);
	}

	public Company getCompanyById(Long companyId) throws DaoException {
		return (Company) this.getHibernateTemplate().load(Company.class,
				companyId);
	}

	public void saveCompany(Company company) throws DaoException {
		this.getHibernateTemplate().save(company);
	}

	public void updateCompany(Company company) throws DaoException {
		this.getHibernateTemplate().update(company);
	}

}
